derivative of a function with respect to a tensor